<template>
  <div>
    <p>D 节点</p>
    <button @click="getARef">获取 A Ref</button>
    <button @click="getERef">获取 E Ref</button>
    <hr />
  </div>
</template>

<script>
export default {
  inject: {
    getParentRef: {
      from: "getRef",
      default: () => {},
    },
    getParentChildrenRef: {
      from: "getChildrenRef",
      default: () => {},
    },
  },
  methods: {
    // 获取祖先级 Ref
    getARef() {
      console.log(this.getParentRef());
    },
    // 获取同级 Ref
    getERef() {
      console.log(this.getParentChildrenRef("childrenE"));
    },
  },
};
</script>
